package com.jiangyg.mall.coupon.controller;

import com.jiangyg.mall.core.support.restful.Result;
import com.jiangyg.mall.coupon.dto.SkuConcessionDTO;
import com.jiangyg.mall.coupon.service.SkuConcessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 类描述：sku优惠
 *
 * @author jiangyg
 * @date 2021-11-13
 */
@RestController
@RequestMapping("/coupon/concession")
public class SkuConcessionController {

    private final SkuConcessionService concessionService;

    @Autowired
    public SkuConcessionController(SkuConcessionService concessionService) {
        this.concessionService = concessionService;
    }

    /**
     * 功能描述：保存商品优惠信息
     *
     * @param request 请求
     * @param dto     商品优惠信息
     * @return 结果
     */
    @ResponseBody
    @PostMapping("/save")
    public Result<Object> save(HttpServletRequest request, @RequestBody @Validated SkuConcessionDTO dto) {
        return Result.saveOrUpdate(concessionService.save(dto));
    }

}
